import { defineConfig, loadAndConvertEnv } from '@vben/vite-config';

import { getPluginsList } from './build/plugins';

export default defineConfig(async () => {

  const { base,baseURL, outDir, port } = await loadAndConvertEnv();
  return {
    application: {},
    vite: {
      build: {
        emptyOutDir: true,
        outDir,
      },
      plugins: getPluginsList(),
      server: {
        base,
        port,
        host:true,
        proxy: {
          '/api': {
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, ''),
            // mock代理目标地址
            target: `${baseURL}/api`,
            ws: true,
          },
          '/portal': {
            changeOrigin: true,
            // 这里填写后端地址
            target: baseURL,
          },
        },
      },
    },
  };
});
